package com.jay.syncdrawing.utils;

import com.jay.syncdrawing.DrawingApp;
import com.jay.syncdrawing.R;

import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

public class ToastUtils {
	public static void showToast(String content) {
		// LayoutInflater这个类用来实例化XML文件到其相应的视图对象的布局
		LayoutInflater inflater = LayoutInflater.from(DrawingApp.getInstance());
		// 通过制定XML文件及布局ID来填充一个视图对象
		View layout = inflater.inflate(R.layout.view_toast, null);
		TextView textToast = (TextView) layout.findViewById(R.id.TextToast);
		textToast.setText(content);
		Toast toast = new Toast(DrawingApp.getInstance());
		toast.setGravity(Gravity.CENTER, 0, 0);
		toast.setDuration(Toast.LENGTH_SHORT);
		toast.setView(layout);
		toast.show();
	}
}
